package com.baiqian.doupo.douji;

import com.baiqian.doupo.capability.douqi.IDouQiCapability;
import com.baiqian.doupo.effect.EffectRegistry;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.util.math.AxisAlignedBB;

import java.util.List;

import static net.minecraft.util.EntityPredicates.IS_ALIVE;

public class DouJi_LingHunGanZhi extends DouJi{
    public DouJi_LingHunGanZhi(){
        super("灵魂感知", 4,4,3,-1,1*20,
                0,0.0,0.0,0.0,2,4,false,false);
    }

    @Override
    public void useEx(IDouQiCapability l, PlayerEntity entity) {
        int see_range = l.getLevelBig();
        entity.addPotionEffect(new EffectInstance(EffectRegistry.ling_hun_gan_zhi.get(), 5, 0,false,false,false));
        AxisAlignedBB range = new AxisAlignedBB(
                entity.getPosX()- see_range*3, entity.getPosY() - see_range*3,  entity.getPosZ()-see_range*3,
                entity.getPosX() +see_range*3+1, entity.getPosY() + see_range*3+1,  entity.getPosZ()+see_range*3+1);//表示x，y，z所在的这一个格子
        List<LivingEntity> livingEntities = entity.world.getEntitiesWithinAABB(LivingEntity.class,range,IS_ALIVE);
        for (int i = 0; i < livingEntities.size(); ++i) {
            LivingEntity livingEntity = livingEntities.get(i);
            if(livingEntity.getPosX()!=entity.getPosX()||livingEntity.getPosY()!=entity.getPosY()||livingEntity.getPosZ()!=entity.getPosZ()) {
                EffectInstance effectinstance = new EffectInstance(Effects.GLOWING, 5, 0, false, false, false);
                livingEntity.addPotionEffect(effectinstance);
            }
        }
    }

    @Override
    public void addEffect(LivingEntity entity) {

    }

    @Override
    protected void createEntity(IDouQiCapability l, PlayerEntity playerEntity) {

    }

}
